package com.tupu.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Configuration
    public class UploadConfig {
        @Bean(name = "multipartResolver")
        public MultipartResolver multipartResolver() {
            return new CommonsMultipartResolver();
        }
    }

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射访问绝对路径,配置资源映射
        //registry.addResourceHandler("/api/file/**").addResourceLocations("file:/home/images/");
        //registry.addResourceHandler("/api/file/**").addResourceLocations("file:C:\\Users\\Young\\Desktop\\");
        registry.addResourceHandler("/api/csv/**").addResourceLocations("file:/home/csv/");
    }
}